const path = require('path');

function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
    lintOnSave: 'error',
    productionSourceMap: false,
    devServer: {
        open: true,
        host: '0.0.0.0',
        port: 9100,
        proxy: {
            '/api': {
                target: 'http://192.168.73.222:9011/',
                secure: false,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''
                }
            }
        }
    },

    /* 开启vue运行时模板编译功能！！ */
    // runtimeCompiler: true,

    chainWebpack: config => {
        config.resolve.alias.set('@', resolve('./src'));
        // set vue-markdown-loader
        config.module
            .rule('md')
            .test(/\.md/)
            .use('vue-loader')
            .loader('vue-loader')
            .end()
            .use('vue-markdown-loader')
            .loader('vue-markdown-loader/lib/markdown-compiler')
            .options({
                raw: true
            })
            .end()
    },
    configureWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            return {
                performance: {
                    hints: 'warning',
                    maxEntrypointSize: 5000000,
                    maxAssetSize: 3000000
                }
            };
        }
    }
};
